package com.ruoyi.project.warehouse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.warehouse.domain.RyInventoryCurrentStock;
import com.ruoyi.project.warehouse.service.IRyInventoryCurrentStockService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 产品当前库存Controller
 *
 * @author you
 * @date 2022-09-07
 */
@RestController
@RequestMapping("/warehouse/RyInventoryCurrentStock")
public class RyInventoryCurrentStockController extends BaseController
{
    @Autowired
    private IRyInventoryCurrentStockService ryInventoryCurrentStockService;

    /**
     * 查询产品当前库存列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyInventoryCurrentStock:list')")
    @GetMapping("/list")
    public TableDataInfo list(RyInventoryCurrentStock ryInventoryCurrentStock)
    {
        startPage();
        List<RyInventoryCurrentStock> list = ryInventoryCurrentStockService.selectRyInventoryCurrentStockList(ryInventoryCurrentStock);
        return getDataTable(list);
    }

    /**
     * 导出产品当前库存列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyInventoryCurrentStock:export')")
    @Log(title = "产品当前库存", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RyInventoryCurrentStock ryInventoryCurrentStock)
    {
        List<RyInventoryCurrentStock> list = ryInventoryCurrentStockService.selectRyInventoryCurrentStockList(ryInventoryCurrentStock);
        ExcelUtil<RyInventoryCurrentStock> util = new ExcelUtil<RyInventoryCurrentStock>(RyInventoryCurrentStock.class);
        util.exportExcel(response, list, "产品当前库存数据");
    }

    /**
     * 获取产品当前库存详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyInventoryCurrentStock:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ryInventoryCurrentStockService.selectRyInventoryCurrentStockById(id));
    }

    /**
     * 新增产品当前库存
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyInventoryCurrentStock:add')")
    @Log(title = "产品当前库存", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RyInventoryCurrentStock ryInventoryCurrentStock)
    {
        return toAjax(ryInventoryCurrentStockService.insertRyInventoryCurrentStock(ryInventoryCurrentStock));
    }

    /**
     * 修改产品当前库存
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyInventoryCurrentStock:edit')")
    @Log(title = "产品当前库存", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RyInventoryCurrentStock ryInventoryCurrentStock)
    {
        return toAjax(ryInventoryCurrentStockService.updateRyInventoryCurrentStock(ryInventoryCurrentStock));
    }

    /**
     * 删除产品当前库存
     */
    @PreAuthorize("@ss.hasPermi('warehouse:RyInventoryCurrentStock:remove')")
    @Log(title = "产品当前库存", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ryInventoryCurrentStockService.deleteRyInventoryCurrentStockByIds(ids));
    }
}
